package com.sansui.blog.utils;

/**
 * @name: StrSpilt
 * @author: Sansui
 * @Software: IDEA
 * @Blog: https://www.cnblogs.com/sansui6/
 * @date: 2022-11-27 20:21
 **/

//字符串截取  日常,正则表达式,HTML选择器,学习,爬虫  to '日常','正则表达式','HTML选择器','学习','爬虫'
public class StrSpilt {

    public static String strSpilt(String str) {
        StringBuffer sb = new StringBuffer();
        String[] temp = str.split(",");
        for (int i = 0; i < temp.length; i++) {
            if (!"".equals(temp[i]) && temp[i] != null)
                sb.append("'" + temp[i] + "',");
        }
        String result = sb.toString();
        String tp = result.substring(result.length() - 1, result.length());
        if (",".equals(tp)){
            return result.substring(0, result.length() - 1);
        } else{
            return result;
        }
    }

}
